<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 300px;

        }
    </style>
</head>

<body>
    <img src="/Users/humeng/Pictures/IMG_9228.JPG" alt="">
    <div>上午好!</div>

    <script>
        var img = document.querySelector('img');
        var div = document.querySelector('div');
        //得到当前的时间
        var date = new Date();
        var hours = date.getHours();
        console.log(hours);
        //判断小时数
        if (hours < 12) {
            img.src = '/Users/humeng/Pictures/IMG_9228.JPG';
            div.innerHTML = '上午好';
        } else if (hours < 18) {
            img.src = '/Users/humeng/Pictures/截屏2022-05-07 14.10.01.png';
            div.innerHTML = '下午好';
        } else {
            img.src = '/Users/humeng/Pictures/截屏2022-05-07 13.55.54.png';
            div.innerHTML = '晚上好';
        }
    </script>

</body>

</html>